﻿namespace instamuz.Application.BootstrapperTasks
{
    using System.Web.Mvc;
    using System.Web.Routing;
    using JetBrains.Annotations;
    using MvcExtensions;

    [UsedImplicitly]
    public class RegisterRoutes : RegisterRoutesBase
    {
        public RegisterRoutes(RouteCollection routes)
            : base(routes)
        {
        }

        protected override void Register()
        {
            Routes.IgnoreRoute("{*allashx}", new { allashx = @".*\.ashx(/.*)?" });
            Routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            Routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });

            Routes.MapRoute("id", "{id}", new { controller = "index", action = "index" }, new { controller = "index", action = "index", id = @"[A-z._-]+" });
            
            Routes.MapRoute("controller/action/page/id", "{controller}/{action}/p{page}/{id}", new { }, new { id = "[0-9]+", page = "[0-9]+" });
            Routes.MapRoute("controller/action/page", "{controller}/{action}/p{page}", new { }, new { page = "[0-9]+" });
            Routes.MapRoute("controller/action/id", "{controller}/{action}/{id}", new { }, new { id = "[0-9]+" });
            Routes.MapRoute("controller/action", "{controller}/{action}", new { controller = "index", action = "index" });
        }
    }
}